package com.zhb.cloud.service.impl;

import org.springframework.beans.factory.annotation.Autowired;

import com.zhb.cloud.service.GeneralService;
import com.zhb.cloud.mapper.GeneralMapper;
import com.github.pagehelper.PageInfo;

/**
 * @ClassName: GeneralServiceImpl
 * @Description: 通用操作
 * @author: zhb1316783262@163.com
 * @date: 2019年1月31日下午4:14:59
 */
public class GeneralServiceImpl<T> implements GeneralService<T> {

	@Autowired
	private GeneralMapper<T> mapper;

	@Override
	public T findById(int id) {
		return mapper.selectByPrimaryKey(id).get();
	}

	@Override
	public int save(T model) {
		return mapper.insertSelective(model);
	}

	@Override
	public int update(T model) {
		return mapper.updateByPrimaryKeySelective(model);
	}

	@Override
	public int delete(int id) {
		return mapper.deleteByPrimaryKey(id);
	}

	@Override
	public PageInfo<T> page(int pageNum, int pageSize) {
		return null;
	}
}
